<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <meta http-equiv="X-UA-Compatible" content="IE=edge" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>Document</title>
  </head>
  <body>
    <div id="wrap">123</div>
  </body>

  <script>
    +(function (w, d) {
      /* 自执行函数 */
      // 声明 jQuery
      const jQuery = function (selector) {
        this.dom = d.querySelector(selector);
        return this.dom;
      };

      // 可以实现无 new 构造
      w.$ = function (selector) {
        return new jQuery(selector);
      };
    })(window, document);

    console.log($);
    console.log($("body"));
    console.log($("#wrap"));

    $("#wrap").innerHTML = "hello world!";
  </script>
</html>
